<template>
  <button @click="parentClick">调用子组件方法</button>
  <div>{{ childData }}</div>
  <YcChildVue ref="childRef" @on-ChildClick="parentClick2"></YcChildVue>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue';
import YcChildVue from './YcChild.vue';
//在组件挂载后，和子组件childRef
const childRef = ref<InstanceType<typeof YcChildVue>>()
const childData = ref("")
const parentClick = () => {
  childRef.value?.childClick()
  childData.value = childRef.value!!.childData
}
const parentClick2 = () => {
  console.log("这是父组件");
}

</script>